﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace dahtd4ever
{
    public class DOT
    {
        float damage;
        bool tick = false;
        int tickCount = 0;
        int tickCountMax;

        public bool active = true;

        TimeSpan tickSpeed;
        TimeSpan lastTick;

        public DOT(TimeSpan tickSpeed, int tickCount, float damage)
        {
            this.tickSpeed = tickSpeed;
            this.tickCountMax = tickCount;
            this.damage = damage;
            lastTick = new TimeSpan();
        }

        public void Update(Enemy e, Game1 g, GameTime gt)
        {

            if (tickCount < tickCountMax)
            {

                if (gt.TotalGameTime > lastTick + tickSpeed)
                {
                    tick = true;
                    lastTick = gt.TotalGameTime;
                }

                if (tick)
                {
                    e.setHp(e.getHp() - this.damage);
                    tick = false;
                    tickCount++;
                }
            }

            else { this.active = false; }

        }

    }
}
